import { templateApi } from '@/api'
import type { Template003ParamsType, GetTopTagTotalResultItem, GetTopTagDetailsResult, QuerySangitaChartsResult } from '@/api/modules/template'

export type { GetTopTagTotalResultItem, GetTopTagDetailsResult, QuerySangitaChartsResult }
export function useLoadData() {
  const tagTotalData = ref<GetTopTagTotalResultItem[]>()
  const tagDetailsData = ref<GetTopTagDetailsResult>()
  const tagChartData = ref<QuerySangitaChartsResult>()

  async function getTopTagTotal(params: Template003ParamsType) {
    const { data } = await templateApi.getTopTagTotal(params)
    tagTotalData.value = data
    return data
  }

  async function getTopTagDetails(params: Template003ParamsType) {
    const { data } = await templateApi.getTopTagDetails(params)
    tagDetailsData.value = data
    return data
  }

  async function querySangitaCharts(params: Template003ParamsType) {
    const { data } = await templateApi.querySangitaCharts(params)
    tagChartData.value = data
    return data
  }
  return {
    tagTotalData,
    tagDetailsData,
    tagChartData,
    getTopTagTotal,
    getTopTagDetails,
    querySangitaCharts,
  }
}
